import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store/index'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/css/main.css'
import 'babel-polyfill'
import VCharts from 'v-charts'

Vue.use(ElementUI)
Vue.use(VCharts)

router.beforeEach(function (to, from, next) {
  if (to.path !== "/Login") {
    //页面是否登录
    if (sessionStorage.getItem("admin")) {
      //本地存储中是否有user(uid)数据
      next(); //表示已经登录
    } else {
      //next可以传递一个路由对象作为参数 表示需要跳转到的页面
      next({
        path: "/Login",
        // query: { redirect: from.fullPath },
      });
    }
  } else {
    //表示不需要登录
    next(); //继续往后走
  }
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
